#ifndef LAPLACE_H
#define LAPLACE_H

#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET

#include <Eigen/Sparse>
#include "core/engine/mesh_definition.h"

#include <vcg/simplex/face/topology.h>
#include <wrap/io_trimesh/export.h>

#include <QDebug>

class LaplaceOperator
{

    public:
        //the operator
        LaplaceOperator(CGMesh& m);

        //apply laplacian smoothing on the mesh for a certain number of times
        void LaplaceSmoothing(int iter);


        void LaplaceSmoothingDirect(int iter, QString type);

    private:
        //the mesh itself
        CGMesh& mesh;

        //Laplacian coefficient matrix
        Eigen::DynamicSparseMatrix< float > weights;   //W matrix
        Eigen::DynamicSparseMatrix< float > areas;     //A matrix

        //compute weight associated with the edge ej of face fp
        float getWeight( int fp, int ej );

        //compute the mixed area of face fp related to the vertex vj
        float getMixedArea( int fp, int vj );

};

#endif // LAPLACE_H
